#!/bin/bash
expect -c "
 set timeout 100;
 spawn sshpass -p oh4xPGwXVrhU ssh root@43.156.246.194;
 expect {
     *~]*
     {
      send \"cd /root\r\";
      send \"mkdir fangnan_python_project\r\";
      send \"cd /root/fangnan_python_project\r\";
      send \"rm -rf django-forum-main.tar.gz\r\";
      send \"wget --ftp-user=xbftp  --ftp-password='xiaobu2016' ftp://120.79.102.124/django-forum-main.tar.gz\r\";
      send \"rm -rf /root/fangnan_python_project/DjangoForum-main\r\";
      send \"tar -zxvf django-forum-main.tar.gz\r\";
      send \"cd /root/fangnan_python_project/DjangoForum-main\r\";
      send \"/usr/local/python3/bin/python3.10 -m pip install -r requirements.txt \r\";
      send \"kill $(lsof -i:80 -t) \r\"
      send \"nohup /usr/local/python3/bin/python3.10 manage.py runserver 0.0.0.0:80 > /root/django-forum-main.log 2>&1 & \r\";
#      send \"/usr/local/python3/bin/python3.10 manage.py runserver 0.0.0.0:80 \r\";
      send \"tail -f /root/django-forum-main.log\r\";

    }
  }
  interact
"
